package com.nbjtjc.safe.mapper.emg;

import com.nbjtjc.safe.bean.Page;
import com.nbjtjc.safe.model.emg.EmgGoods;
import com.nbjtjc.safe.model.emg.EmgGoodsLog;
import com.nbjtjc.util.MyMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmgGoodsLogMapper extends MyMapper<EmgGoodsLog> {

    List<EmgGoodsLog> search(@Param("log") EmgGoodsLog emgGoodsLog, @Param("page") Page page);
    @Select(" SELECT" +
            "    emg_goods_log.*, emg_goods.goods_name AS goodsName," +
            "    emg_goods_type.unit AS goodsUnit," +
            "    sys_user.username AS registerUser" +
            "    FROM " +
            "    emg_goods_log " +
            "    LEFT JOIN emg_goods ON emg_goods.id = emg_goods_log.goods_id " +
            "    LEFT JOIN emg_goods_type ON emg_goods.goods_name = emg_goods_type.name " +
            "    LEFT JOIN sys_user ON sys_user.user_id = emg_goods_log.register_id" +
            "  where emg_goods_log.id=#{id}")
    EmgGoodsLog findById(@Param("id") int id);

    @Select("select * from emg_goods_log where goods_log_id=#{id}")
    List<EmgGoodsLog> findByGoodsLogId(@Param("id") int id);
}